﻿/**************************************************************
 *
 * 唯一标识：fa1250e4-0af8-4664-9fec-02c5a21ddc16
 * 命名空间：Sgr.OrganizationAggregate
 * 创建时间：2023/8/3 10:03:13
 * 机器名称：DESKTOP-S0D075D
 * 创建者：antho
 * 电子邮箱：fengqinhua2016@163.com
 * 描述：
 *
 **************************************************************/

using Sgr.Domain.Repositories;
using System.Threading.Tasks;
using System.Threading;

namespace Sgr.UPMS.Domain.Organizations
{
    /// <summary>
    /// 组织机构仓储
    /// </summary>
    public interface IOrganizationRepository : ITreeNodeBaseRepositoryOfTEntityAndTPrimaryKey<Organization, long>
    {
        /// <summary>
        /// 检查识别码是否唯一
        /// </summary>
        /// <param name="code"></param>
        /// <param name="excludedId"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task<bool> CodeIsUniqueAsync(string code, long? excludedId = null, CancellationToken cancellationToken = default);

        /// <summary>
        /// 批量检查识别码是否存在
        /// </summary>
        /// <param name="identificationCodes">待检查的识别码列表</param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns>已存在的识别码集合</returns>
        Task<HashSet<string>> GetExistingIdentificationCodesAsync(
            IEnumerable<string> identificationCodes,
            CancellationToken cancellationToken = default);
    }
}